package models

import (
	"ginchat/utils/structs"
	"time"
)

type UserModel struct {
	UserId        string    `gorm:"column:user_id;primaryKey;type:varchar(30);not null;" json:"user_id" form:"user_id"`
	UserName      string    `gorm:"column:user_name;type:varchar(50);" json:"user_name" form:"user_name"`
	Password      string    `gorm:"column:password;type:varchar(255);" json:"password" form:"password"`
	Email         string    `gorm:"column:email;type:varchar(100);" json:"email" form:"email"`
	ClientIp      string    `gorm:"column:client_ip;type:varchar(20);" json:"client_ip" form:"client_ip"`
	ClientPort    string    `gorm:"column:client_port;type:varchar(30);" json:"client_port" form:"client_port"`
	HeartbeatTime int64     `gorm:"column:heartbeat_time;type:bigint;" json:"heartbeat_time" form:"heartbeat_time"`
	LoginTime     int64     `gorm:"column:login_time;type:bigint;" json:"login_time" form:"login_time"`
	LogoutTime    int64     `gorm:"column:logout_time;type:bigint;" json:"logout_time" form:"logout_time"`
	Phone         string    `gorm:"column:phone;type:varchar(30);" json:"phone" form:"phone"`
	DeviceInfo    string    `gorm:"column:device_info;type:varchar(255);" json:"device_info" form:"device_info"`
	CreateTime    time.Time `gorm:"column:create_time;type:datetime;default:CURRENT_TIMESTAMP;" json:"create_time" form:"create_time"`
	UpdateTime    time.Time `gorm:"column:update_time;type:datetime;default:CURRENT_TIMESTAMP;" json:"update_time" form:"update_time"`
	IsDeleted     bool      `gorm:"column:is_deleted;type:tinyint(1);" json:"is_deleted" form:"is_deleted"`
}

func (m *UserModel) TableName() string {
	return "user"
}

func (m *UserModel) GetUserId() string {
	return m.UserId
}

func (m *UserModel) SetUserId(UserId string) {
	m.UserId = UserId
}

func (m *UserModel) GetUserName() string {
	return m.UserName
}

func (m *UserModel) SetUserName(UserName string) {
	m.UserName = UserName
}

func (m *UserModel) GetPassword() string {
	return m.Password
}

func (m *UserModel) SetPassword(Password string) {
	m.Password = Password
}

func (m *UserModel) GetEmail() string {
	return m.Email
}

func (m *UserModel) SetEmail(Email string) {
	m.Email = Email
}

func (m *UserModel) GetClientIp() string {
	return m.ClientIp
}

func (m *UserModel) SetClientIp(ClientIp string) {
	m.ClientIp = ClientIp
}

func (m *UserModel) GetClientPort() string {
	return m.ClientPort
}

func (m *UserModel) SetClientPort(ClientPort string) {
	m.ClientPort = ClientPort
}

func (m *UserModel) GetHeartbeatTime() int64 {
	return m.HeartbeatTime
}

func (m *UserModel) SetHeartbeatTime(HeartbeatTime int64) {
	m.HeartbeatTime = HeartbeatTime
}

func (m *UserModel) GetLoginTime() int64 {
	return m.LoginTime
}

func (m *UserModel) SetLoginTime(LoginTime int64) {
	m.LoginTime = LoginTime
}

func (m *UserModel) GetLogoutTime() int64 {
	return m.LogoutTime
}

func (m *UserModel) SetLogoutTime(LogoutTime int64) {
	m.LogoutTime = LogoutTime
}

func (m *UserModel) GetPhone() string {
	return m.Phone
}

func (m *UserModel) SetPhone(Phone string) {
	m.Phone = Phone
}

func (m *UserModel) GetDeviceInfo() string {
	return m.DeviceInfo
}

func (m *UserModel) SetDeviceInfo(DeviceInfo string) {
	m.DeviceInfo = DeviceInfo
}

func (m *UserModel) GetCreateTime() time.Time {
	return m.CreateTime
}

func (m *UserModel) SetCreateTime(CreateTime time.Time) {
	m.CreateTime = CreateTime
}

func (m *UserModel) GetUpdateTime() time.Time {
	return m.UpdateTime
}

func (m *UserModel) SetUpdateTime(UpdateTime time.Time) {
	m.UpdateTime = UpdateTime
}

func (m *UserModel) GetIsDeleted() bool {
	return m.IsDeleted
}

func (m *UserModel) SetIsDeleted(IsDeleted bool) {
	m.IsDeleted = IsDeleted
}

func (m *UserModel) GetModelMap() (map[string]interface{}, error) {
	return structs.StructToMap(m, "json")
}

func (m *UserModel) Assign(in interface{}) {
	structs.StructAssign(m, in, "json")
}
